/*
 *      Author : Pallab
 *      Prog: 1420.cxx
 *
 *      Created on: 08:22:50 PM - 2013:2:23
 * "I have not failed, I have just found 10000 ways that won't work."
 */
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;


#define foR(i,frm,upto) for( int i=(frm),_i=(upto);(i) < (_i) ; ++i )
#define foD(i,frm,upto) for( int i=(frm),_i=(upto);(i) >= (_i) ; --i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define dbg(...)       printf(__VA_ARGS__)
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")
#define getchar getchar_unlocked
inline void wait ( double seconds ) {
    double endtime = clock() + ( seconds * CLOCKS_PER_SEC );
    while ( clock() < endtime ) {
        ;
    }
}
template<class T>
    inline T fastIn() {
    register char c=0;
    register T a=0;
    bool neg=false;
    while ( c<33 ) c=getchar();
    while ( c>33 ) {
        if ( c=='-' ) {
            neg=true;
        } else {
            a= ( a*10 ) + ( c-'0' );
        }
        c=getchar();
    }
    return neg?-a:a;
}
inline int readword ( char *buffer ) {
    int c, cnt = 0;
    c = getchar();
    while ( c >= 0 && c <= ' ' ) {
        c = getchar();
    }
    if ( c < 0 ) {
        buffer[cnt] = 0;
        return cnt;
    }
    while ( c > ' ' ) {
        buffer[cnt++] = c;
        c = getchar();
    }
    buffer[cnt] = 0;
    return cnt;
}
int const mod=1000000007;
inline int domod ( int x ) {
    x%=mod;
    if ( x<0 ) x+=mod;
    return mod;
}
int const mxn=105;
char A[mxn],B[mxn],C[mxn];
int la,lb,lc;
inline void read() {
    la=readword ( A ),lb=readword ( B ),lc=readword ( C );
}
struct state {
    int v,f;
    state() {
        v=f=0;
    }
    state ( int _v,int _f ) {
        v=_v,f=_f;
    }
};
state dp[mxn][mxn][mxn][3];
int curKase=1;
#define siga 0
#define sigb 1
#define sigab 2
inline int go ( int a,int b,int c,int sig ) {
    if ( c>=lc ) return 1;

    state &d = dp[a][b][c][sig];
    if ( d.f==curKase ) return d.v;
    d.f=curKase;
    d.v=0;


    if ( sig==siga||sig==sigab ) {
        foR ( ai,a,la ) {
            if ( A[ai]==C[c] ) {
                d.v+=go ( ai+1,b,c+1, sigab );
                if ( d.v>=mod ) d.v-=mod;
                d.v+=go ( ai+1,b,c,siga );
                if ( d.v>=mod ) d.v-=mod;
                break;
            }
        }
    }
    if ( sig==sigb||sig==2 ) {
        foR ( bi,b,lb ) {
            if ( B[bi]==C[c] ) {
                d.v+=go ( a,bi+1,c+1,sigab );
                if ( d.v>=mod ) d.v-=mod;
                d.v+=go ( a,bi+1,c,sigb );
                if ( d.v>=mod ) d.v-=mod;
                break;
            }
        }
    }

    return d.v;
}
inline void proc() {
    //dbg ( "%s %s %s %d %d %d\n",A,B,C,la,lb,lc );
    int retval=go ( 0,0,0 ,2 ) ;
    cout<<retval<<"\n";
    ++curKase;
}
int main() {
    int kase = 1;
#if defined( xerxes_pc )
    if ( !freopen ( "in1", "r", stdin ) )
        puts ( "error opening file in " ), assert ( 0 );
    kase = 1;
#endif
    kase=fastIn<int>();
    foR ( i,1,kase+1 ) {
        read();
        cout<<"Case "<<i<<": ";
        proc();
    }
    return 0;
}
// kate: indent-mode cstyle; indent-width 4; replace-tabs on; 



